package com.lantu.draw.svgimg.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.AllowedMethods;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.lantu.image.UploadTool;
import com.opensymphony.xwork2.ActionSupport;
//sturt2参考guild https://cwiki.apache.org/confluence/display/WW/Result+Types
@Action("/upload")  
@AllowedMethods(value={"input","execute"})
@Results( { 
	@Result(name = "page", location = "base64-img-upload.jsp"),
	@Result(name = "success", location = "base64-img-upload.jsp")
})
public class Base64UploadAction extends ActionSupport{
	private String base64;//获取base64字符串


    public String getBase64() {
        return base64;
    }


    public void setBase64(String base64) {
        this.base64 = base64;
    }

    public String input()  {
    	return "page";
    	
    }
    @Override
    public String execute() throws Exception {
        try {
            String fileUrl = UploadTool.upload(base64);
            System.out.println("上传文件路径是：" + fileUrl);
        } catch(Exception e) {
        	e.printStackTrace();
            
        }
        return super.execute();
    }
}
